<?php
class Shop_Model_Observer_ClearCacheAll extends Promotor_Observable_Observer_Abstract {
	public function update(Promotor_Observable_List $list) {
		$product = new Shop_Model_Product();
		$promotion = new Shop_Model_Promotion();
		
		$manufacturer = new Shop_Model_Manufacturer();
		$category = new Shop_Model_Category();
		$image = new Shop_Model_Image();

		try {
			$result = $product->getResultCache()->clean(
				Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
				array(get_class($product))
			);
			$result = $promotion->getResultCache()->clean(
				Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
				array(get_class($promotion))
			);
			$result = $manufacturer->getResultCache()->clean(
				Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
				array(get_class($manufacturer))
			);
			$result = $category->getResultCache()->clean(
				Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
				array(get_class($category))
			);
			$result = $image->getResultCache()->clean(
				Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
				array(get_class($image))
			);

			$status = $result ? self::SUCCESS : self::FAILURE;
			$this->_setStatus($status);
		} catch (Zend_Cache_Exception $e) {
			$this->_addException($e);
			$this->_setStatus(self::FAILURE);
		}
	}
}